﻿/*
 * 
 * Made with love by Unixfreak August 2010
 * 
 * 
*/
using System;
using System.Collections.Generic;
using System.Text;

namespace Server.Quiz
{
 public class ScoreBoard
    {
        private SortedDictionary<string, byte> scoreList = new SortedDictionary<string, byte>();
        public void Add(string name)
        {
            if (scoreList.ContainsKey(name))
            {
                scoreList[name]++;
            }
            else
            {
                scoreList.Add(name, 1);
            }
        }
        public void Clear()
        {
            scoreList.Clear();
        }
        public string Print()
        {
            String tmp = "";
            String msg = "";
            tmp = "Current scores are:" + "\r\n";
            if (scoreList.Count > 0)
            {
                foreach (KeyValuePair<string, byte> pair in scoreList)
                {
                    msg = pair.Value == 1 ? " point!" : " points!";
                    tmp += pair.Key + " with " + pair.Value + msg + "\r\n";
                }
            }
            else
            {
                tmp = "No scores";
            }
            return tmp;
        }

    }
}